package cn.zswltech.gruul.web.api.util;

import cn.tongdun.data.standard.common.encrypt.AESCBCEncryptor;
import cn.tongdun.data.standard.common.encrypt.SymmetricEncryptor;
import cn.tongdun.data.standard.common.exception.DataStandardException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class EncryptHandler {
    private static final Logger logger = LoggerFactory.getLogger(EncryptHandler.class);

    private SymmetricEncryptor aescbcEncryptor;

    @PostConstruct
    public void init(){

        aescbcEncryptor = new AESCBCEncryptor("7ED3649982E23AB7", "5C39B694BE641E8B");
    }
    public String encryptBase64ByAES(String value) throws DataStandardException {
        return aescbcEncryptor.encryptBase64(value);
    }

    public String decryptBase64ByAES(String value) throws DataStandardException {
        return aescbcEncryptor.decryptBase64(value);
    }
}